﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace FFWorker
{
    public partial class MainForm : Form
    {
        private static AppSettings ApplSettings;
        private DeleteEmptyFolders DEFComponent;
        private DeleteFolderByName DFBNComponent;
        private AboutBox About;
        private ActionArbiter ActArbiter;

        public MainForm()
        {
            InitializeComponent();
            //DEFComponent = new DeleteEmptyFolders(DeleteEmptyFoldersGroupBox, OutputWindow);
            About = new AboutBox();

            DataGridViewRow rowTempl = this.OutView.RowTemplate;
            rowTempl.Height = 20;

            DEFComponent = new DeleteEmptyFolders(DeleteEmptyFoldersGroupBox, OutView);
            DFBNComponent = new DeleteFolderByName(DeleteFoldersByNameGroupBox, OutView);

            ActArbiter = new ActionArbiter();
            ActArbiter.RegisterAction("DEF", (DeleteEmptyFolders)DEFComponent);
            ActArbiter.RegisterAction("DFBN", (DeleteFolderByName)DFBNComponent);
        }

        private void MainLoad(object sender, EventArgs e)
        {
            ApplSettings = new AppSettings();
        }

        private void MainClose(object sender, FormClosedEventArgs e)
        {
            ApplSettings.Save();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            About.Show();
        }

        private void deleteEmptyFoldersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ActArbiter.ActivateAction("DEF");
        }

        private void deleteFoldersByNameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ActArbiter.ActivateAction("DFBN");
        }

        private void DEFChooseFolderButton_Click(object sender, EventArgs e)
        {
            DEFComponent.DEFChooseFolderEvent(ApplSettings.DefaultDEFDirectory);
        }

        private void DFBN_ChooseFolder_Click(object sender, EventArgs e)
        {
            DFBNComponent.DFBNChooseFolderEvent(ApplSettings.DefaultDFBNDirectory);
        }

        private void DEFExecuteButton_Click(object sender, EventArgs e)
        {
            DEFComponent.DEFDeleteFolderEvent();
        }

        private void DFBNDeleteButton_Click(object sender, EventArgs e)
        {
            DFBNComponent.DFBNDeleteFolderEvent();
        }
    }
}
